<template>
	<view class="page">

		<view class="page-content ">
			<view class="p13 pt15">
				<view class="bg-white brs10 mb20" v-for="(item,index) in dataList" :key="index" @click="toInfo(item)">
					<view class="u-flex" style="align-items: flex-start;">
						<image :src="item.picUrl" style="width: 180rpx;height: 180rpx;" mode="aspectFill"></image>
						<view class="pl12 u-f1">
							<view class="fz14">
								{{item.spuName}}
							</view>
							<!-- <view class="fz14 u-flex u-f-jsb u-font-bold mt25" style="color: #FE3307;">
								￥169.9
							</view> -->
							<view class="fz12 c9 mt50  u-flex u-f-jsb">
								{{item.createTimeFormat}}
								<span class="fz12 c9" @click.stop="toCancle(item.id,index)">取消收藏</span>
							</view>

						</view>
					</view>




				</view>

				<view class="mt20">

					<u-loadmore :status="loadStatus" v-if="dataList.length>0" />
				</view>
				<view class="order-none u-flex u-f-justify fz16 c9 p50" v-if="dataList.length<=0">
					暂无数据~
				</view>
			</view>
		</view>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				statusAttr: ['', '待签到', '已签到', '已取消'],
				list: [{
					name: '全部',
					id: '',
				}, {
					name: '待付款',
					id: '1'
				}, {
					name: '待发货',
					id: '2'
				}, {
					name: '待收货',
					id: '3'
				}, {
					name: '已完成',
					id: '4'
				}, ],
				loadStatus: 'more',
				scrollHeight: 300,
				dataList: [],
				page: 1,
			}
		},
		onLoad(e) {
			if (e.tab) {
				this.current = e.tab
			}
		},
		onShow() {
			this.$nextTick(() => {
				this.initData()
			})
		},
		// 页面下拉到底部触发
		onReachBottom() {
			if (this.loadStatus == 'more') {
				this.getData()
			}
		},
		methods: {
			toCancle(id,index) {

				this.$api.productCorrectDel({
					id
				}, res => {
					if (res.code == 200) {

						this.dataList.splice(index, 1)
					} else {

						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				})
			},
			toInfo(item) {
				uni.navigateTo({
					url: '/pages/product/info?id=' + item.spuId
				})
			},
			change(e) {
				this.current = e
				this.initData()
			},
			initData() {
				this.page = 1
				this.dataList = []
				this.getData()
			},
			getData() {
				this.$api.productCorrectList({
					pageNo: this.page,
					pageSize: 10
				}, res => {
					if (res.code) {
						let _list = res.data.list
						this.dataList = [...this.dataList, ..._list]
						// 判断所有数据是否请求完毕
						if (res.data.total > this.dataList.length) {
							this.page++
							this.loadStatus = 'more'
						} else {
							this.loadStatus = 'noMore'
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btn {

		width: 184rpx;
		height: 64rpx;
		text-align: center;
		color: #fff;
		line-height: 64rpx;
		background: #70B52C;
		border-radius: 16rpx;
	}

	.line {
		width: 750rpx;
		height: 4rpx;
		position: relative;
		top: -4rpx;
		background: #F6F9F9;
		border-radius: 0px 0px 0px 0px;
	}

	.status1 {
		color: #E54440;
	}

	.status2 {
		color: #39959B;
	}

	.status3 {
		color: #333;
	}
</style>